<template>
	<view>
		<u-cell-group>
			<u-cell         
				title="图文标题"
				value="内容"
				center
			>
			<template #value>
				<view>
					<u-input
					  placeholder="例如: xx月xx日,日结兼职岗位招聘"
					  border="surround"
					  v-model="this.$officePost.create.createPost.title"
					></u-input>
				</view>
			</template>
			

			</u-cell>
			
			<u-cell
				title="描述"
				value="内容"
				center
			>
				<template #value>
					<view style="flex: 2;">
						<u--textarea v-model="this.$officePost.create.createPost.digest" placeholder="请输入内容" :height="150"  count autoHeight></u--textarea>
					</view>
				</template>
			</u-cell>
			
			<u-cell
				title="图文封面"
				center
			>
				<template #value>
					<view>
						<u-upload
							:fileList="fileList1"
							@afterRead="afterRead"
							@delete="deletePic"
							name="1"
							multiple
							:maxCount="1"
							:sizeType="['original', 'compressed']"
						></u-upload>
					</view>
				</template>		
			</u-cell>
				
<!-- 			<u-cell
				title="图文描述"
				value="内容"
				label="描述信息"
				center
			>
				<template #value>
					<u-rate :count="count" v-model="star"></u-rate>
				</template>		
			</u-cell> -->
		</u-cell-group>
		
		<view style="padding-top: 60px;"></view>
		
		<view @click="showComfirmModal=true" style="
			position: fixed;bottom: 0;
			left:0;right:0;
			height: 60px;
			display: flex;
			align-items: center;
			background-color: white;
			border-top: solid 1rpx #eee;
			"
		>
			<view @click="onCreateComfirm" style="
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 10rpx 0rpx;
				border-radius: 10rpx;
				box-shadow: 0 0 14px 0 #66666635;
				border: solid 1rpx #ddd;
				top:10px;bottom: 10px;left:10px;right: 10px; 
				position: absolute;
			">
					确定创建
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				postTemplate:{
					title:'',
					digest:'',
					html:'',
					thumb_url:''
				},
				count: 4,
				value: "",
				value1:'',
				star:2,
				fileList1:[]
			}
		},
		onLoad(){
			var digest = this.$officePost.create.createPost.html.replaceAll(/(<[^>]*>)/g,'').replaceAll(/[\s\n]/g,'')
			console.log(digest)
			digest = digest.substr(0,50)
			console.log(digest)
			
			this.$officePost.create.createPost.digest = digest
		},
		methods: {
			async afterRead (event) {
				
				console.log(JSON.stringify(event))
				this.fileList1.push({
					...event.file[0],
					status: 'success',
					message: ''
				}) 
				
				this.$officePost.create.createPost.thumb_url = event.file[0].url
			},
			deletePic(){
				
			},
			async onCreateComfirm(){
				console.log(this.$officePost.create.createPost)
				const res = await this.$http.post('/common/wx/create_post',this.$officePost.create.createPost)
				console.log(res)
			}
		}
	}
</script>

<style>

</style>
